<?php defined("SYSPATH") or die("No direct script access.")?>
<div class="box" style="text-align: left; height: auto;">
<? if (isset($basket->contents ) && count($basket->contents) > 0){ ?>
<table width="100%" cellpadding="0" cellspacing="0" style="border:1px solid rgb(221, 221, 221);">
<tr style="width: 100%">
	<td >
		รูปสินค้า
	</td>
</tr>
<?php $total=0;$fc=0;?>
<? foreach ($basket->contents as $key => $basket_items){ ?>
<?php $style =""; if($fc%2==0){$style = "background-color: #f7fbff";}else{$style = "background-color: #ffffff";} $fc++;?>
<?php $product=$basket_items->getProduct();?>
<?php $total+=$basket_items->quantity*$product->price?>
<tr valign="top"  style="<?=$style?>;width: 100%;">
	<td width="200px;">
		<a href="<?php echo url::base(FALSE).''.$product->image?>" class="preview-image"> 
		<img src="<?php echo url::base(FALSE).''.$product->thumbnail?>"
		title="<?= $product->description?>" alt="" /> 
		</a><br />
	</td>
	<td valign="top">
		<table style="width: 100%">
			<tr valign="top">
				<td colspan="5"><?= $product->description ?></td>
			</tr>
			<tr valign="top">
				<td>ราคา </td>
				<td><label><?=$product->price?></label></td>
				<td>จำนวน</td>
				<td >
					&nbsp;&nbsp;<input style="border:1px solid #982A11;color:blue;text-align: right;width: 50px;" id="<?=$key?>" type="text" value="<?=$basket_items->quantity?>">
					&nbsp;&nbsp;<input type="hidden" id="<?=$key?>" value="<?=$basket_items->quantity?>">
				</td>
				<td style="width: 200px;" >
				<a href="javascript:updateQuantity('<?=$key?>');" 
				class="g-button ui-state-default ui-corner-all ui-icon-left"> <span
				class="ui-icon ui-icon-trash"></span>Add quantity</a>&nbsp;&nbsp;&nbsp;
				<a href="<?= url::site("basket/remove_item/$key")?>"
				class="g-button ui-state-default ui-corner-all ui-icon-left"> <span
				class="ui-icon ui-icon-trash"></span>Remove</a>
				</td>
			</tr>
		</table>
	</td>
</tr>
<?php }?>
</table>
	<div style="border:1px solid #982A11;color:blue;">
	<?php echo "<br/>&nbsp;&nbsp;&nbsp;  ราคารวมทั้งหมด :: $total  บาท<br/><br/>"?>
	</div>
<?php }?>
</div>
<form name="formbasket" id="formbasket">

</form>
<script type="text/javascript">
function updateQuantity(key){
	var params="/"+key+"/"+document.getElementById(key).value;
	document.formbasket.action="<?=url::site("basket/add_item")?>"+params;
	//alert(document.formbasket.action);
	document.formbasket.submit();
}
</script>